import React from "react";
import { Redirect } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";
import { loginAction } from "./actions";

const Login = () => {
    const dispatch = useDispatch();
    const { userinfo } = useSelector((state) => state.a);
    if (userinfo.token) {
        return <Redirect to="/" />;
    }
    const login = () => {
        dispatch(loginAction({ username: "fdy101", passwd: 1234567 }));
    };
    return (
        <div>
            登录
            <br />
            <button onClick={login}>登录</button>
        </div>
    );
};

export default Login;
